<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="./css/bootstrap.min.css" rel="stylesheet">
<link href="./css/font-awesome.min.css" rel="stylesheet">
<link href="./css/animate.min.css" rel="stylesheet">
<link href="css/jquery-confirm.css" rel="stylesheet">
<link href="./css/plugins/summernote/summernote.css" rel="stylesheet">
<link href="./css/plugins/summernote/summernote-bs3.css"
	rel="stylesheet">
<link href="./css/style.min.css" rel="stylesheet">
<link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<link href="css/plugins/iCheck/custom.css" rel="stylesheet">
<script src="./js/My97DatePicker/WdatePicker.js"></script>
<script src="js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="./js/img_upload.js"></script>
<script type="text/javascript" src="./js/fileUploadUtil.js"></script>
<script src="js/plugins/modal/bootstrap-modal.js"></script>
<script src="js/jquery-confirm.js"></script>
<script src="js/plugins/iCheck/icheck.min.js"></script>
<script src="js/common.js"></script>
<title>滨海基金 -客户详情</title>
</head>
<body class="gray-bg">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5>
						个人 <small>资料</small>
					</h5>
				</div>

				<div class="ibox-content" style="padding-top: 0px">
					<form method="post" class="form-horizontal m-t" id="editForm"
						enctype="multipart/form-data">
						<div class="modal-body" align="center" style="padding-top: 0px">
							<div class="row form-body form-horizontal m-t">
								<div class="col-md-6 droppable sortable">
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">员工姓名： </label>
										<div class="col-sm-8">
											<input type="text" name="name" id="edit-name"
												value="${user.name }" class="form-control"
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">账号： </label>
										<div class="col-sm-8">
											<input type="text" name="userCard" id="edit-userCard"
												value="${user.userCard }" class="form-control"
												disabled="disabled">
										</div>

									</div>
									<!-- <div class="form-group draggable">
									<label class="col-sm-3 control-label">密码：</label>
									<div class="col-sm-8">

										<input name="password" id="edit-password" class="form-control"
											type="password" placeholder="请输入密码">
									</div>
								</div> -->
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">性别： </label>
										<div class="col-sm-8">
											<select class="form-control" name="sex" id="sex">
												<option
													<c:if test="${user.sex eq '男'}" >selected="selected"</c:if>>男</option>
												<option
													<c:if test="${user.sex eq '女'}" >selected="selected"</c:if>>女</option>
											</select>
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">角色： </label>
										<div class="col-sm-8">
											<input type="text" name="rid" id="edit-role"
												class="form-control" value="${user.role.rname}"
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">隶属单位： </label>
										<div class="col-sm-8">
											<input type="text" name="deptId" id="edit-dept"
												class="form-control" value="${user.dept.deptName}"
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">隶属部门： </label>
										<div class="col-sm-8">
											<input type="text" name="branchId" id="edit-branch"
												class="form-control" value="${user.branch.branchName }"
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">隶属团队： </label>
										<div class="col-sm-8">
											<input type="text" name="teamId" id="edit-team"
												class="form-control" value="${user.team.branchName}"
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">职务：</label>
										<div class="col-sm-8">
											<input type="text" name="position" id="edit-position"
												class="form-control" value="${user.position}"
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-3 control-label">岗位：</label>
										<div class="col-sm-8">
											<input type="text" name="quarters" id="edit-quarters"
												class="form-control"
												<c:if test="${user.quarters eq 0 }">value="无"</c:if>
												<c:if test="${user.quarters eq 1 }">value="团队长"</c:if>
												<c:if test="${user.quarters eq 2 }">value="部门经理"</c:if>
												<c:if test="${user.quarters eq 3 }">value="分部负责人"</c:if>
												<c:if test="${user.quarters eq 7 }">value="分部运营"</c:if>
												<c:if test="${user.quarters eq 8 }">value="分部人事"</c:if>
												<c:if test="${user.quarters eq 4 }">value="总部一般人员"</c:if>
												<c:if test="${user.quarters eq 5 }">value="总部管理人员"</c:if>
												<c:if test="${user.quarters eq 6 }">value="总部负责人"</c:if>
												disabled="disabled">
										</div>
									</div>
								</div>

								<div class="col-md-6 droppable sortable">
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">头像：</label>
										<div class="col-sm-6" style="padding-right: 0px">
											<input type="file" name="hotelImgFile" id="hotelImgFile"
												class="form-control" multiple="multiple" value="更换头像"
												value="${user.employeeId}" style="display: none">
											<div class="input-append">
												<input id="photoCover" type="text" class="form-control"
													vlaue="${user.picture}" readonly="readonly">
											</div>

											<input type="hidden" name="picture" id="edit-picture"
												value="${user.picture}" /> <input type="hidden"
												name="operation" value="修改"> <input type="hidden"
												name="employeeId" id="edit-employeeId"
												value="${user.employeeId}"><input type="hidden"
												name="equipment" value="pc">
										</div>
										<div class="col-sm-1" style="padding-left: 0px">
											<a class="btn btn-default" style="border-radius: 0px;"
												onclick="$('input[id=hotelImgFile]').click();">浏览</a>
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">入职日期：</label>
										<div class="col-sm-7" style="padding-right: 0px">
											<input type="text" name="serviceYear" id="serviceYear"
												class="form-control"
												onClick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})"
												placeholder="请选择生效日期"
												value='<fmt:formatDate 
										value="${user.serviceYear }" pattern="yyyy-MM-dd" />'
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">身份证号码：</label>
										<div class="col-sm-7" style="padding-right: 0px">
											<input type="text" name="idCard" id="edit-idCard"
												class="form-control" placeholder="请输入身份证号码"
												value="${user.idCard}">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">出生日期：</label>
										<div class="col-sm-7" style="padding-right: 0px">
											<input type="text" name="birthday" id="birthday"
												class="form-control"
												onClick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})"
												placeholder="请选择出生日期"
												value='<fmt:formatDate 
										value="${user.birthday }" pattern="yyyy-MM-dd" />'>
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">在职情况：</label>
										<div class="col-sm-7" style="padding-right: 0px">
											<input type="text" name="workConditions"
												id="edit-workConditions" class="form-control"
												value="<c:if test="${user.workConditions eq 0}">在职</c:if><c:if test="${user.workConditions eq 1}">请假</c:if><c:if test="${user.workConditions eq 2}">休假</c:if>"
												disabled="disabled">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">手机号码：</label>
										<div class="col-sm-7" style="padding-right: 0px">
											<input type="text" name="phoneNumber" id="edit-phoneNumber"
												class="form-control" placeholder="请输入手机号码"
												value="${user.phoneNumber }">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">电子邮箱： </label>
										<div class="col-sm-7" style="padding-right: 0px">
											<input type="text" name="email" class="form-control"
												placeholder="请输入电子邮箱" id="edit-email" value="${user.email }">
										</div>
									</div>
									<div class="form-group draggable">
										<label class="col-sm-4 control-label">住址：</label>
										<div class="col-sm-7" style="padding-right: 0px">
											<input type="text" name="address" id="edit-address"
												class="form-control" placeholder="请输入住址"
												value="${user.address }">
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="modal-footer" align="center">
							<div align="center" id="btd">
								<button type="button" class="btn btn-info"
									onclick="updateEmployee()">确认</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			//检查email邮箱
			function isEmail(str) {
				// var reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
				var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
				return reg.test(str);
			}
			//检查手机号码
			function isPhone(str) {
				var reg = /^1[34578]\d{9}$/;
				return reg.test(str);
			}
			//修改用户信息
			function updateEmployee() {
				var editEmail = $("#edit-email").val();
				var editPhoneNumber = $("#edit-phoneNumber").val();
				var editAddress = $("#edit-address").val();
				var isEmailResult = isEmail(editEmail);
				if (editEmail != null && editEmail != "" && !isEmailResult) {
					swal("提示!", "电子邮箱输入有误!", "error");
					return false;
				}
				if (editPhoneNumber.length != 11) {
					swal("提示!", "请输入正确手机号码!", "error");
					return false;
				}
				if (editAddress.length > 100) {
					swal("提示!", "住址太长!", "error");
					return false;
				}
				/* var password = $("#edit-password").val();
				if (trim(password) == ""&&password == null) {
					swal("请输入密码!", "温馨提示!", "error");
					return false;
				} */
				FileUpload("insertEmployee.do", "#editForm", function(data) {
					if (data.code == 1 || data.code == 2) {
						swal({
							title : "提示",
							text : "添加成功！",
							type : "success",
							confirmButtonText : "确定",

						}, function() {
							$('#editForm')[0].reset();
							//location = "userDetail.do?id=1?v=4.0";
							parent.window.triggerB();
						});
					} else {
						swal("提示!", "保存失败!", "error");
					}
				}, function(loaded, total) {
					//可添加模版，提示正在上传；
				}, function() {

				}, function() {
					swal("提示!", "服务器访问失败!", "error");
				});
			}
		</script>

		<script type="text/javascript">
			var darw = 0;
			$(function() {

				//选择头像之后的事件
				$("#hotelImgFile").change(
						function() {
							var file = $("#hotelImgFile");

							var suffix = file.val().substring(
									file.val().lastIndexOf(".") + 1,
									file.val().length);
							var picture = file.val().substring(
									file.val().lastIndexOf("\\") + 1,
									file.val().length);

							var imageSize = file[0].files[0].size / 1024;//kb
							suffix=suffix.toLowerCase();
							//JPG,JPEG,PNG,BMP,GIF格式
							if (suffix != "jpg" && suffix != "jpeg"
									&& suffix != "png" && suffix != "bmp"
									&& suffix != "gif") {
								file.val("");//清空
								sweetAlert("提示",
										"仅支持10M以下JPG,JPEG,PNG,BMP,GIF格式图片!",
										"error");
							} else if (imageSize > 1024 * 5) { //仅支持5M内的图片
								file.val("");//清空
								sweetAlert("提示", "图片文件的大小不能超过5M!", "error");
							} else {
								$("#picture").val(file.val());
							}

						});

			})
			//图片上传赋值事件
			$('input[id=hotelImgFile]').change(function() {
				$('#photoCover').val($(this).val());
			});
		</script>
</body>
</html>